import store from '@/store/index.js'

const permissions = {
	verify: (code) => {
		let bool = false;
		const userInfo = store.state.userInfo;
		const resource = [];
		console.log("code", code)
		if (!userInfo) {
			bool = false;
		} else if (userInfo.admin) {
			bool = true;
		} else {
			userInfo.roles.forEach(item => {
				if (item.permissions) {
					resource.push(...item.permissions)
				}
			})
			bool = resource.includes(code)
		}
		return bool;
	}
}

export default permissions;